//
//  ATTwoViewController.m
//  NSTimerDemo
//
//  Created by lianglibao on 2018/11/13.
//  Copyright © 2018年 lianglibao. All rights reserved.
//

#import "ATTwoViewController.h"
#import "ATTimer.h"


@interface ATTwoViewController ()
@property (nonatomic, strong) NSTimer *timer;
@end

@implementation ATTwoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"TWO";
    self.view.backgroundColor = [UIColor lightGrayColor];
    
    //[self setuptTimer];
    
    [self setupATTimer];
}

- (void)setuptTimer {
    self.timer = [NSTimer timerWithTimeInterval:1.0
                                         target:self
                                       selector:@selector(timerAction)
                                       userInfo:nil
                                        repeats:YES];
    [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
    [self.timer fire];
}

- (void)setupATTimer {
    [[ATTimer sharedInstance] setupTimerWithName:NSStringFromClass(self.class)
                                    timeInterval:1.0
                                          target:self
                                        selector:@selector(timerAction)
                                         repeats:YES];
}

- (void)timerAction {
    NSLog(@"%s", __func__);
}

- (void)dealloc {
    NSLog(@"%s", __func__);
    [self.timer invalidate];
    self.timer = nil;
}

@end
